package com.feemanage.domain.vo;

import com.common.annotation.Excel;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.framework.config.BigDecimalSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

/**
 * 项目分类经费执行率
 */
@Data
@ApiModel("项目分类执行率")
public class ProjectTypeExecuteVo {

    private static final long serialVersionUID = 1L;


    @ApiModelProperty("项目分类代码")
    private String projectTypeCode; //项目分类代码

    @Excel(name = "项目分类名称")
    @ApiModelProperty("项目分类名称")
    private String projectTypeCodeName; //项目分类名称

    @Excel(name = "立项年度")
    @ApiModelProperty("立项年度")
    private String authorizeDate; //立项年度

    @Excel(name = "执行周期")
    @ApiModelProperty("执行周期")
    private String executeYear; //执行周期

    @Excel(name = "到账率",cellType = Excel.ColumnType.STRING,suffix = "%")
    @ApiModelProperty("到账率")
    @JsonSerialize(using = BigDecimalSerializer.class)
    private BigDecimal incomeRate; //到账率

    @JsonSerialize(using = BigDecimalSerializer.class)
    private BigDecimal incomeFee; //到账金额

    @JsonSerialize(using = BigDecimalSerializer.class)
    private BigDecimal payoutFee; //支出金额

    @JsonSerialize(using = BigDecimalSerializer.class)
    private BigDecimal feeAuthorize; //合同金额

    @Excel(name = "执行率",cellType = Excel.ColumnType.STRING,suffix = "%")
    @ApiModelProperty("执行率")
    @JsonSerialize(using = BigDecimalSerializer.class)
    private BigDecimal executeRate; //执行率

    @ApiModelProperty("上级节点")
    private String upCode; //上级节点

    @ApiModelProperty("项目分类子节点")
    private List<ProjectTypeExecuteVo> children;


    public static Comparable getField(ProjectTypeExecuteVo obj, String field) {
        switch (field) {
            case "project_type_code_name":
                return obj.getProjectTypeCodeName();
            case "AUTHORIZE_DATE":
                return obj.getAuthorizeDate();
            case "execute_year":
                return obj.getExecuteYear();
            case "incomeRate":
                return obj.getIncomeRate().toString();
            case "executeRate":
                return obj.getExecuteRate().toString();
            default:
                throw new IllegalArgumentException("无效的字段名: " + field);
        }
    }
}
